$(function(){
	//tab
	tab("category li","category_con table","on");
	
});
//tab切换
function tab(menuclass,tabclass,onclass)
{
	$("."+menuclass).click(function()
	{ 
		$(this).addClass(onclass).siblings().removeClass(onclass);
		var index = $("."+menuclass).index(this);
		$("."+tabclass).eq(index).show().siblings().hide();
	});
}

//已转账
function bankTransfer(id){
	var list = art.dialog.list;
	for (var i in list) {
		list[i].close();
	}
	art.dialog({
				title : "提示",
				content : "确定已经转账了吗？",
				lock : true,
				fixed : true,
				drag : true,
				ok : function() {
					$.post("mall/order/bankTransfer/view/" + id, {}, 
					function(data) {
								var icon = "succeed";
								if (!data.result)
									icon = "warning";
								list = art.dialog.list;
								for (var i in list) {
									list[i].close();
								};
								art.dialog({
											icon : icon,
											esc : true,
											content : data.message,
											lock : true,
											fixed : true,
											drag : true,
											ok : true,
											init : function() {
												var that = this, i = 10;
												var fn = function() {
													that.title(i + '秒后自动关闭');
													!i && that.close();
													i--;
												};
												tip_timer = setInterval(fn, 1000);
												fn();
											},
											close : function() {
												clearInterval(tip_timer);
												if (data.result) {
													window.location.href = getRootUrl()+"mall/order/view/"+id;
												}
											}
										}).time(10);
							});
				},
				cancel : true
			});
		}
		
		
		function receiptInvoice(positionVal,orderNo,pkId){	       
			$.post("mall/order/receiptInvoice/" + positionVal + "/" + orderNo, {}, function(data) {
					var icon = "succeed";
					if (!data.result)
						icon = "warning";
					list = art.dialog.list;
					for (var i in list) {
						list[i].close();
					};
					art.dialog({
								icon : icon,
								esc : true,
								content : data.message,
								lock : true,
								fixed : true,
								drag : true,
								ok : true,
								init : function() {
									var that = this, i = 10;
									var fn = function() {
										that.title(i + '秒后自动关闭');
										!i && that.close();
										i--;
									};
									tip_timer = setInterval(fn, 1000);
									fn();
								},
								close : function() {
									clearInterval(tip_timer);
									if (data.result) {
										if ("index" == positionVal)
											window.location.href = getRootUrl()+"index";
										else{
											var pageNum = $("#page").val();
											if (!window.console || !console.firebug){
													var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
													window.console = {};
													for (var i = 0; i < names.length; ++i)
													window.console[names[i]] = function(){} 
											}
											console.log("page = "+console.log(pageNum));
											window.location.href = getRootUrl()+"mall/order/view/"+pkId;
										}
											
									}
								}
							}).time(10);
				});
	}